package com.ruoyi.project.dict.kangxizi.service.impl;

import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.framework.aspectj.lang.annotation.DataSource;
import com.ruoyi.framework.aspectj.lang.enums.DataSourceType;
import com.ruoyi.project.dict.kangxizi.domain.KangxiZi;
import com.ruoyi.project.dict.kangxizi.mapper.KangxiZiMapper;
import com.ruoyi.project.dict.kangxizi.service.IKangxiZiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 康熙字典Service业务层处理
 *
 * @author shixiangwen
 * @date 2021-06-22
 */
@Service
@DataSource(DataSourceType.DICT)
public class KangxiZiServiceImpl implements IKangxiZiService {

    @Autowired
    private KangxiZiMapper kangxiZiMapper;

    /**
     * 查询康熙字典
     *
     * @param id 康熙字典ID
     * @return 康熙字典
     */
    @Override
    public KangxiZi selectKangxiZiById(Long id) {
        return kangxiZiMapper.selectKangxiZiById(id);
    }

    /**
     * 查询康熙字典列表
     *
     * @param kangxiZi 康熙字典
     * @return 康熙字典
     */
    @Override
    public List<KangxiZi> selectKangxiZiList(KangxiZi kangxiZi) {
        List<KangxiZi> zis = kangxiZiMapper.selectKangxiZiList(kangxiZi);
        zis.forEach(item -> {
            item.setZi(new String(item.getZiBytes()));
        });
        return zis;
    }

    /**
     * 新增康熙字典
     *
     * @param kangxiZi 康熙字典
     * @return 结果
     */
    @Override
    public int insertKangxiZi(KangxiZi kangxiZi) {
        return kangxiZiMapper.insertKangxiZi(kangxiZi);
    }

    /**
     * 修改康熙字典
     *
     * @param kangxiZi 康熙字典
     * @return 结果
     */
    @Override
    public int updateKangxiZi(KangxiZi kangxiZi) {
        return kangxiZiMapper.updateKangxiZi(kangxiZi);
    }

    /**
     * 删除康熙字典对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteKangxiZiByIds(String ids) {
        return kangxiZiMapper.deleteKangxiZiByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除康熙字典信息
     *
     * @param id 康熙字典ID
     * @return 结果
     */
    @Override
    public int deleteKangxiZiById(Long id) {
        return kangxiZiMapper.deleteKangxiZiById(id);
    }
}
